package com.xy.controller.home;

import com.xy.common.base.ApiBaseResponse;
import com.xy.entity.product.Picture;
import com.xy.repository.PictureRespository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(value = "首页图片Controller", description = "首页图片")
@RestController
@RequestMapping(value = "api/picture")
public class IndexController {
    @Autowired
    private PictureRespository pictureRespository;

    @ApiOperation("图片")
    @GetMapping("/AllPictures")
    @ResponseStatus(HttpStatus.OK)
    public ResponseEntity<?> Allpicture() {
        String sort = "首页";
        List<Picture> list = pictureRespository.findAllBySort(sort);
        return ResponseEntity.ok(ApiBaseResponse.fromHttpStatus(HttpStatus.OK, list));
    }
}